# -*- tcl -*-
# -------------------------------------------------------------------------
# critcl_util_def.test
# -------------------------------------------------------------------------

source [file join [file dirname [info script]] support testutilities.tcl]

testsNeedTcl     8.4
testsNeedTcltest 2

support {
    useLocal lib/lassign84/lassign.tcl  lassign84
    useLocal lib/dict84/dict.tcl     dict84

    useLocal lib/stubs_container/container.tcl stubs::container
    useLocal lib/stubs_reader/reader.tcl       stubs::reader
    useLocal lib/stubs_genframe/genframe.tcl   stubs::gen

    useLocal lib/critcl/critcl.tcl critcl

    # Helper procedures
    useLocalFile test/support/crit_utils.tcl
}
testing {
    useLocal lib/critcl-util/util.tcl critcl::util
}

overrides

# -------------------------------------------------------------------------
## util::def syntax

test critcl-util-def-1.0.6 {util-def, wrong\#args, not enough} -constraints tcl8.6plus -body {
    critcl::util::def
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.0.5 {util-def, wrong\#args, not enough} -constraints tcl8.5 -body {
    critcl::util::def
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.0.4 {util-def, wrong\#args, not enough} -constraints tcl8.4 -body {
    critcl::util::def
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.1.6 {util-def, wrong\#args, not enough} -constraints tcl8.6plus -body {
    critcl::util::def C
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.1.5 {util-def, wrong\#args, not enough} -constraints tcl8.5 -body {
    critcl::util::def C
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.1.4 {util-def, wrong\#args, not enough} -constraints tcl8.4 -body {
    critcl::util::def C
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.2.6 {util-def, wrong\#args, too many} -constraints tcl8.6plus -body {
    critcl::util::def C D V X
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.2.5 {util-def, wrong\#args, too many} -constraints tcl8.5 -body {
    critcl::util::def C D V X
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

test critcl-util-def-1.2.4 {util-def, wrong\#args, too many} -constraints tcl8.4 -body {
    critcl::util::def C D V X
} -returnCodes error -result {wrong # args: should be "critcl::util::def configfile define ?value?"}

# -------------------------------------------------------------------------
##

test critcl-util-def-2.0 {util-def} -setup {
    set here [critcl::cache]
    file mkdir    ~/.critcl-tests-[pid]
    critcl::cache ~/.critcl-tests-[pid]
} -body {
    critcl::util::def C foo 333
    inspect C
} -cleanup {
    critcl::cache $here
    unset here
    file delete -force ~/.critcl-tests-[pid]
} -result [viewFile [localPath test/assets/def-2.0]]

# -------------------------------------------------------------------------
testsuiteCleanup

# Local variables:
# mode: tcl
# indent-tabs-mode: nil
# End:
